{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "\"\"\" 完美立方\n",
    "形状如 a^3 = x^3 + y^3 + z^3 \n",
    "对于任意给定的的N (N<=100),寻找所有的四员组，其中a,b,c,d大于1，小于等于N,且b<=c<=d\n",
    "\"\"\"\n",
    "\n",
    "def cube(n):\n",
    "    for a in range(2,n):\n",
    "        for x in range(2,a):\n",
    "            for y in range(x,a):\n",
    "                for z in range(y, a):\n",
    "                    if a*a*a == x*x*x + y*y*y + z*z*z:\n",
    "                        print(f\"Cube={a}, Tiple = {x},{y},{z}\")\n",
    "\n",
    "\n",
    "# for n in range(2,100):\n",
    "print(cube(100))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "\"\"\" 生理周期\n",
    "人的体力，情商，之上的高峰日子，分别在每隔23天，28天和33天出现一次。对于每个人想知道3个高峰落在\n",
    "同一天。\n",
    "给定3个高峰出现的日子p,e,i，再给定一个指定的日子d，任务是输出日子d之后，下一次3个高峰落在同一天的日志，\n",
    "用距离d的天数表示；输入4个整数，p,e,i和d，分别表示体力，情感和智力高峰出现的日子，d是给定的日子\n",
    "，可能小于p,e,i，所有给定的日子非负且小于等于365，所求的日子小于或等于21252\n",
    " \"\"\"\n",
    "\n",
    "def find_luck_date(p,e,i,d):\n",
    "    k = d\n",
    "    while True:\n",
    "        k += 1\n",
    "        if (k-p)%23 == 0 and k <= 21252:\n",
    "            break\n",
    "    while True:\n",
    "        k += 23\n",
    "        if (k-e)%28 == 0  and k <= 21252:\n",
    "            break\n",
    "    while True:\n",
    "        k += 23*28\n",
    "        if (k-i)%33 == 0  and k <= 21252:\n",
    "            break\n",
    "    date = k - d\n",
    "    return date\n",
    "\n",
    "if __name__ == \"__main__\":\n",
    "    luckyDate = find_luck_date(p=35,e=44,i=90,d=120)\n",
    "    print(luckyDate)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "称硬币\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
